package com.thinkfit.jy.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.common.lib.activity.BaseActivity;
import com.common.lib.mvp.contract.EmptyContract;
import com.common.lib.mvp.presenter.EmptyPresenter;
import com.thinkfit.jy.R;
import com.thinkfit.jy.utils.DeviceTypeUtils;
import com.thinkfit.jy.view.DragFloatActionButton;
import com.thinkfit.jy.view.LoginResultCallback;

/**
 * 初始页
 */
@SuppressLint("CustomSplashScreen")
public class SplashActivity extends BaseActivity<EmptyContract.Presenter> implements EmptyContract.View {


    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }


    @Override
    protected void onCreated(@Nullable Bundle savedInstanceState) {
//        buttonbackFloat();
//        switch (DataManager.Companion.getInstance().getMainStyle()) {
//            case 0:
//                openActivity(MainActivity.class);
//                break;
//            case 1:
//                openActivity(MainADActivity.class);
//                break;
//            case 2:
//                openActivity(MainBMWActivity.class);
//                break;
//            case 3:
//                openActivity(MainXMActivity.class);
//                break;
//        }

        openActivity(MainActivity.class);

    }


    @NonNull
    @Override
    protected EmptyContract.Presenter onCreatePresenter() {
        return new EmptyPresenter(this);
    }

    @Override
    public void onClick(View v) {
    }


    @Override
    protected void onStop() {
        super.onStop();
        System.out.println("ddddddddddddddddddddddd   SplashActivity ");
        DeviceTypeUtils.showBackButton(getApplicationContext());
    }

    public  void  buttonbackFloat(){
        DragFloatActionButton floatActionButton =new DragFloatActionButton(context,true,new LoginResultCallback());
        WindowManager  windowManager =(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        //设置layoutParasm相关参数
        WindowManager.LayoutParams windowMangerParams= new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_TOAST,
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);
        windowMangerParams.gravity= Gravity.LEFT|Gravity.TOP;
        windowMangerParams.x=0;
        windowMangerParams.y=0;

        floatActionButton.measure(0,0);
        floatActionButton.setOriginWidth(floatActionButton.getMaxWidth()-50);
        windowMangerParams.width=floatActionButton.getOriginWidth();
        windowMangerParams.height=windowMangerParams.width;
        windowManager.addView(floatActionButton,windowMangerParams);

        // 悬浮
    }

}